<!-- company表单弹窗 -->
<form id="company-form" lay-filter="company-form" class="layui-form model-form">
    <input name="id" type="hidden"/>
    <div class="layui-form-item">
        <label class="layui-form-label">公司名称</label>
        <div class="layui-input-block">
            <input name="companyName" placeholder="请输入公司名称" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司位置</label>
        <div class="layui-input-block">
            <input name="address" placeholder="请输入公司位置" type="text" class="layui-input" maxlength="25"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否融资</label>
        <div class="layui-input-block">
            <input name="financing" placeholder="请输入是否融资" type="text" class="layui-input" lay-verify="required"
                   required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司发展</label>
        <div class="layui-input-block">
            <input name="companyDevelop" placeholder="请输入公司发展方向" type="text" class="layui-input" maxlength="50"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司简介</label>
        <div class="layui-input-block">
            <input name="companyProfile" placeholder="请输入公司简介" type="text" class="layui-input"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司优势</label>
        <div class="layui-input-block">
            <input name="companyAdvantage" placeholder="请输入公司优势" type="text" class="layui-input"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司人数</label>
        <div class="layui-input-block">
            <input id="wage" name="companyTechniciansNum" placeholder="请输入公司人数"  type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司成立于（年）</label>
        <div class="layui-input-block">
            <input name="companyEstablish" placeholder="请输入公司成立时间（年）" type="text" class="layui-input" maxlength="10"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">评价</label>
        <div class="layui-input-block">
            <input name="evaluation" placeholder="请输入评价" type="text" class="layui-input"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item model-form-footer">
        <button class="layui-btn layui-btn-primary" ew-event="closeDialog" type="button">取消</button>
        <button class="layui-btn" lay-filter="company-form-submit" lay-submit>保存</button>
    </div>
</form>

<script>
    layui.use(['layer', 'admin', 'form', 'formSelects'], function () {

        var layer = layui.layer;
        var admin = layui.admin;
        var form = layui.form;
        var formSelects = layui.formSelects;


        form.render('radio');


        // 回显user数据
        var company = admin.getTempData('t_company');
        if (company) {
            form.val('company-form', company);
        }
        // 表单提交事件
        form.on('submit(company-form-submit)', function (data) {
            layer.load(2);

            if (data.field.id!=null && data.field.id!=''){
                admin.req('api-company/company/updateCompany', JSON.stringify(data.field), function (data) {
                    layer.closeAll('loading');
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 500});
                        admin.finishPopupCenter();
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 500});
                    }
                }, 'POST');
                return false;
            }else{
                admin.req('api-company/company/addCompany', JSON.stringify(data.field), function (data) {
                    layer.closeAll('loading');
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 500});
                        admin.finishPopupCenter();
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 500});
                    }
                }, 'POST');
                return false;
            }

        });
    });
</script>